package com.zzyl.controller;

import com.zzyl.base.PageResponse;
import com.zzyl.base.ResponseResult;
import com.zzyl.dto.NursingLevelDto;
import com.zzyl.entity.NursingLevel;
import com.zzyl.service.NursingLevelService;
import com.zzyl.vo.NursingLevelVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@Api(tags = "护理级别相关接口")
@RequiredArgsConstructor
@RequestMapping("/nursingLevel")
public class NursingLevelController {
    private final NursingLevelService nursingLevelService;
    @GetMapping("/listAll")
    @ApiOperation(value = "查询所有护理级别")
    public ResponseResult selectAll() {
        List<NursingLevelVo> nursingLevel= nursingLevelService.findAll();
        return ResponseResult.success(nursingLevel);
    }
    @PostMapping()
    @ApiOperation(value = "新增护理级别")
    public ResponseResult addNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.addNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }
    @GetMapping("/listByPage")
    @ApiOperation(value = "分页查询护理级别")
    public ResponseResult selectPage(String name,Integer status,Integer pageNum,Integer pageSize) {
        PageResponse<NursingLevelVo> nursingLevel=nursingLevelService.selectPage(name,status,pageNum,pageSize);
        return ResponseResult.success(nursingLevel);
    }
    @GetMapping("/{id}")
    @ApiOperation(value = "根据id查询护理级别")
    public ResponseResult selectById(@PathVariable("id") Long id) {
        NursingLevelVo nursingLevel=nursingLevelService.selectById(id);
        return ResponseResult.success(nursingLevel);
    }
    @PutMapping("/update")
    @ApiOperation(value = "修改护理级别")
    public ResponseResult updateNursingLevel(@RequestBody NursingLevelDto nursingLevelDto) {
        nursingLevelService.updateNursingLevel(nursingLevelDto);
        return ResponseResult.success();
    }
    @PutMapping("/{id}/status/{status}")
    @ApiOperation(value = "禁用启用护理级别")
    public ResponseResult startOrStop(@PathVariable Long id,@PathVariable Integer status) {
        nursingLevelService.startOrStop(id,status);
        return ResponseResult.success();
    }
    @DeleteMapping("/{id}")
    @ApiOperation(value = "删除护理级别")
    public ResponseResult deleteById(@PathVariable("id") Long id) {
        nursingLevelService.deleteById(id);
        return ResponseResult.success();
    }
}
